package IU;

import Entidades.Localidad;
import Entidades.Operario;
import Entidades.Pais;
import Entidades.Provincia;
import java.util.List;
import java.util.Vector;
import javax.swing.JOptionPane;
import utiles.Validador;
import Controladores.CtrlAMBOperario;
import Controladores.CtrlEstadoOperario;
import Controladores.CtrlLocalidad;
import Controladores.CtrlPais;
import Controladores.CtrlProvincia;
import Controladores.CtrlRol;
import Controladores.CtrlTipodocumento;
import Controladores.CtrlOperariorol;
import Controladores.CtrlArea;
import Controladores.CtrlCargo;
import Controladores.CtrlTransportista;

import Entidades.Estadooperario;
import Entidades.Rol;
import Entidades.Tipodocumento;
import Entidades.Area;
import Entidades.Cargo;
import Entidades.Transportista;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collection;
import java.util.ArrayList;
import java.util.Iterator;

/**
 *
 * @author  Laura
 * 
 * 
 */
public class ABMTransportista extends javax.swing.JFrame {

    private String apellido, nombre, tipodoc, cuil, direccion, codigopostal, fechaAlta, fechaBaja;
    private String pais;
    private String provincia;
    private String localidad;
    String numerodoc;
    int telefono1;
    int telefono2;
    Transportista transportista;
    TablaPersonalizada tableModel;
    //  private List listarol, listaarea, listacargo;
    CtrlAMBOperario controladorop;
    CtrlPais controladorpais;
    CtrlProvincia controladorprov;
    CtrlLocalidad controladorlocal;
    CtrlTipodocumento controladortd;
    CtrlEstadoOperario controladorep;
    CtrlRol controladorrol;
    CtrlArea controladorarea;
    CtrlCargo controladorcargo;
    CtrlOperariorol controperariorol;
    CtrlTransportista controladortransportista;
    Operario o;
    Validador validador;
    private List listatd, listaprov, listapais, listaloc, listao;
    //acá ver si puedo hacer lo mismo con pais provincia traer la collection de provincia
    Collection<Localidad> localidadesCollection = new ArrayList<Localidad>();
    Estadooperario miestado = null;
    String rol;
    Rol rolper;
    Area areaper;
    Cargo cargoper;
    List<Transportista> listaTransportista = new ArrayList<Transportista>();
    Transportista transportistaNro = null;
    Transportista transportistaSel = null;
    Tipodocumento tipo = null;
    int numero = 0;
    private List listat;
    private final String op;

    public ABMTransportista(String operario) {
        initComponents();
        op = operario;
        jTextFieldUsuario2.setText(op);
        controladorop = new CtrlAMBOperario();
        controladorpais = new CtrlPais();
        controladorprov = new CtrlProvincia();
        controladorlocal = new CtrlLocalidad();
        controladortd = new CtrlTipodocumento();
        controladorep = new CtrlEstadoOperario();
        controladorrol = new CtrlRol();
        controladorarea = new CtrlArea();
        controladorcargo = new CtrlCargo();
        controperariorol = new CtrlOperariorol();
        controladortransportista = new CtrlTransportista();
        jPanel4.setVisible(false);

        cargarTipoDocumento();



        cargarTabla();//
        cargarTipoDocumento1();
        cargarComboPaises();
        cargarComboPaises1();
        //   cargarComboProvincias1();
        //cargarComboLocalidades1();
//        cargarComboTransportistas();
        jComboBoxpais.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                rellenaCombo2((String) jComboBoxpais.getSelectedItem());
            }
        });

        rellenaCombo2((String) jComboBoxpais.getSelectedItem());

        jComboBoxprovincia.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                rellenaCombo3((String) jComboBoxprovincia.getSelectedItem());
            }
        });
        rellenaCombo3((String) jComboBoxprovincia.getSelectedItem());

        jComboBoxlocalidad.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                rellenaCombo4((String) jComboBoxlocalidad.getSelectedItem());
            }
        });
        rellenaCombo4((String) jComboBoxlocalidad.getSelectedItem());


        jComboBoxpais1.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                rellenaCombo5((String) jComboBoxpais1.getSelectedItem());
            }
        });

        rellenaCombo5((String) jComboBoxpais1.getSelectedItem());

        jComboBoxprovincia1.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                rellenaCombo6((String) jComboBoxprovincia1.getSelectedItem());
            }
        });
        rellenaCombo6((String) jComboBoxprovincia1.getSelectedItem());

        jComboBoxlocalidad1.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                rellenaCombo7((String) jComboBoxlocalidad1.getSelectedItem());
            }
        });
        rellenaCombo7((String) jComboBoxlocalidad1.getSelectedItem());
        ///  jButtonBuscarCon.setEnabled(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        GestorPesajeJpaPU2EntityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("GestorPesajeJpaPU2").createEntityManager();
        tipodocumentoQuery = java.beans.Beans.isDesignTime() ? null : GestorPesajeJpaPU2EntityManager.createQuery("SELECT t FROM Tipodocumento t");
        tipodocumentoList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : tipodocumentoQuery.getResultList();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jButtonGuardar = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jTextFieldapellido = new javax.swing.JTextField();
        jTextFieldnombre = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jComboBoxtipoDocumento = new javax.swing.JComboBox();
        jLabel12 = new javax.swing.JLabel();
        jTextFieldnumeroDocumento = new javax.swing.JTextField();
        jTextFielddireccion = new javax.swing.JTextField();
        jComboBoxpais = new javax.swing.JComboBox();
        jComboBoxlocalidad = new javax.swing.JComboBox();
        jTextFieldtelefono1 = new javax.swing.JTextField();
        jTextFieldcodigoPostal = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jComboBoxprovincia = new javax.swing.JComboBox();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTableOperarios = new javax.swing.JTable();
        jPanel4 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jTextFieldapellido1 = new javax.swing.JTextField();
        jTextFieldnombre1 = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jComboBoxtipoDocumento1 = new javax.swing.JComboBox();
        jLabel13 = new javax.swing.JLabel();
        jTextFieldnumeroDocumento1 = new javax.swing.JTextField();
        jTextFielddireccion1 = new javax.swing.JTextField();
        jComboBoxpais1 = new javax.swing.JComboBox();
        jComboBoxlocalidad1 = new javax.swing.JComboBox();
        jTextFieldtelefono3 = new javax.swing.JTextField();
        jTextFieldcodigoPostal1 = new javax.swing.JTextField();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jComboBoxprovincia1 = new javax.swing.JComboBox();
        jLabel26 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        eliminar = new javax.swing.JButton();
        modificar = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        ButtBuscar = new javax.swing.JPanel();
        jTextFieldLocalidadListar = new javax.swing.JTextField();
        jLabelDniCon = new javax.swing.JLabel();
        jLabelTelCon = new javax.swing.JLabel();
        jTextFielProvinciaListar = new javax.swing.JTextField();
        jButtonBuscarCon = new javax.swing.JButton();
        jLabelDireccionCon = new javax.swing.JLabel();
        jTextFielPaisListar = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jTextFielDNIListar = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jTextDireccion = new javax.swing.JTextField();
        jTextNombre = new javax.swing.JTextField();
        jTextApellido = new javax.swing.JTextField();
        jButtonSalir = new javax.swing.JButton();
        jPanel7 = new javax.swing.JPanel();
        jTextFieldUsuario2 = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Gestionar Transportista - Sistema Gestor de Pesaje para Bodegas");

        jTabbedPane1.setForeground(new java.awt.Color(102, 0, 102));
        jTabbedPane1.setFont(new java.awt.Font("Segoe UI", 3, 12));

        jButtonGuardar.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jButtonGuardar.setForeground(new java.awt.Color(102, 0, 102));
        jButtonGuardar.setText("Guardar");
        jButtonGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGuardarActionPerformed(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel4.setText("Apellido:");

        jTextFieldapellido.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jTextFieldnombre.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel2.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel2.setText("Nombre:");

        jLabel10.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel10.setText("Tipo Documento:");

        jComboBoxtipoDocumento.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jComboBoxtipoDocumento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxtipoDocumentoActionPerformed(evt);
            }
        });

        jLabel12.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel12.setText("Número Documento:");

        jTextFieldnumeroDocumento.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jTextFielddireccion.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jComboBoxpais.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jComboBoxlocalidad.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jTextFieldtelefono1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jTextFieldcodigoPostal.setEditable(false);
        jTextFieldcodigoPostal.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel16.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel16.setText("Código Postal:");

        jLabel17.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel17.setText("Provincia:");

        jComboBoxprovincia.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel18.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel18.setText("Dirección:");

        jLabel19.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel19.setText("Pais: ");

        jLabel20.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel20.setText("Localidad:");

        jLabel21.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel21.setText("Telefono: ");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButtonGuardar)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                            .addComponent(jLabel18)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jTextFielddireccion))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                            .addComponent(jLabel10)
                            .addGap(18, 18, 18)
                            .addComponent(jComboBoxtipoDocumento, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(jLabel12)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jTextFieldnumeroDocumento, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLabel19)
                                    .addGap(31, 31, 31)
                                    .addComponent(jComboBoxpais, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLabel20)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jComboBoxlocalidad, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLabel21)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jTextFieldtelefono1, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel17)
                                .addComponent(jLabel16))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jTextFieldcodigoPostal)
                                .addComponent(jComboBoxprovincia, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                            .addComponent(jLabel2)
                            .addGap(18, 18, 18)
                            .addComponent(jTextFieldnombre))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                            .addComponent(jLabel4)
                            .addGap(18, 18, 18)
                            .addComponent(jTextFieldapellido))))
                .addContainerGap(381, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTextFieldapellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTextFieldnombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jTextFieldnumeroDocumento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBoxtipoDocumento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12))
                .addGap(48, 48, 48)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel18)
                    .addComponent(jTextFielddireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19)
                    .addComponent(jComboBoxpais, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17)
                    .addComponent(jComboBoxprovincia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel20)
                    .addComponent(jComboBoxlocalidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel16)
                    .addComponent(jTextFieldcodigoPostal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel21)
                    .addComponent(jTextFieldtelefono1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(60, 60, 60)
                .addComponent(jButtonGuardar)
                .addContainerGap(106, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Alta Transportista", jPanel1);

        jScrollPane2.setAutoscrolls(true);

        jTableOperarios.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jTableOperarios.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null}
            },
            new String [] {
                "Apellido", "Nombre", "Tipo Documento", "Nro Documento", "Telefono 1", "Pais", "Provincia", "Localidad"
            }
        ));
        jTableOperarios.setAutoscrolls(false);
        jTableOperarios.setFillsViewportHeight(true);
        jTableOperarios.setMinimumSize(new java.awt.Dimension(55, 55));
        jTableOperarios.setPreferredSize(new java.awt.Dimension(200, 42));
        jTableOperarios.setRowHeight(14);
        jTableOperarios.getTableHeader().setResizingAllowed(false);
        jTableOperarios.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableOperariosMouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(jTableOperarios);

        jScrollPane2.setViewportView(jScrollPane3);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 102, 153))); // NOI18N

        jLabel5.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel5.setText("Apellido:");

        jTextFieldapellido1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jTextFieldapellido1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldapellido1ActionPerformed(evt);
            }
        });

        jTextFieldnombre1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel3.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel3.setText("Nombre:");

        jLabel11.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel11.setText("Tipo Documento:");

        jComboBoxtipoDocumento1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel13.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel13.setText("Número Documento:");

        jTextFieldnumeroDocumento1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jTextFielddireccion1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jComboBoxpais1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jComboBoxlocalidad1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jTextFieldtelefono3.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jTextFieldcodigoPostal1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel24.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel24.setText("Código Postal:");

        jLabel25.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel25.setText("Provincia:");

        jComboBoxprovincia1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel26.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel26.setText("Dirección:");

        jLabel27.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel27.setText("Pais: ");

        jLabel28.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel28.setText("Localidad:");

        jLabel29.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel29.setText("Telefono 1: ");

        eliminar.setFont(new java.awt.Font("Segoe UI", 3, 12));
        eliminar.setForeground(new java.awt.Color(102, 0, 102));
        eliminar.setText("Eliminar");
        eliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                eliminarActionPerformed(evt);
            }
        });

        modificar.setFont(new java.awt.Font("Segoe UI", 3, 12));
        modificar.setForeground(new java.awt.Color(102, 0, 102));
        modificar.setText("Modificar");
        modificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                modificarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addGap(18, 18, 18)
                                .addComponent(jTextFieldnombre1, javax.swing.GroupLayout.DEFAULT_SIZE, 473, Short.MAX_VALUE))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addGap(18, 18, 18)
                                .addComponent(jTextFieldapellido1, javax.swing.GroupLayout.DEFAULT_SIZE, 472, Short.MAX_VALUE)))
                        .addContainerGap(331, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jComboBoxtipoDocumento1, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(26, 26, 26)
                                .addComponent(jLabel13)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextFieldnumeroDocumento1))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel4Layout.createSequentialGroup()
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel26)
                                    .addComponent(jLabel27))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(jPanel4Layout.createSequentialGroup()
                                                .addGap(2, 2, 2)
                                                .addComponent(jComboBoxlocalidad1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                            .addComponent(jComboBoxpais1, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jTextFieldtelefono3, javax.swing.GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE))
                                        .addGap(27, 27, 27)
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addGroup(jPanel4Layout.createSequentialGroup()
                                                .addGap(25, 25, 25)
                                                .addComponent(jLabel25))
                                            .addComponent(jLabel24))
                                        .addGap(18, 18, 18)
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                            .addComponent(jComboBoxprovincia1, javax.swing.GroupLayout.Alignment.LEADING, 0, 179, Short.MAX_VALUE)
                                            .addComponent(jTextFieldcodigoPostal1)))
                                    .addComponent(jTextFielddireccion1, javax.swing.GroupLayout.PREFERRED_SIZE, 478, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(jLabel29, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel28, javax.swing.GroupLayout.Alignment.LEADING))
                        .addGap(128, 128, 128)
                        .addComponent(eliminar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(modificar)
                        .addGap(27, 27, 27))))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jTextFieldapellido1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTextFieldnombre1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(16, 16, 16)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jLabel13)
                    .addComponent(jComboBoxtipoDocumento1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldnumeroDocumento1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel26)
                    .addComponent(jTextFielddireccion1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel27)
                            .addComponent(jComboBoxpais1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel28)
                            .addComponent(jComboBoxlocalidad1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel29)
                            .addComponent(jTextFieldtelefono3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 64, Short.MAX_VALUE)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(eliminar)
                            .addComponent(modificar)))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jComboBoxprovincia1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel25))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldcodigoPostal1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel24))))
                .addContainerGap())
        );

        jButton1.setText("Modificar Datos");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(48, 48, 48)
                .addComponent(jButton1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(59, 59, 59)
                        .addComponent(jButton1)))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Modificar/Eliminar", jPanel2);

        ButtBuscar.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Datos del Transportista", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 12), new java.awt.Color(102, 0, 102))); // NOI18N

        jTextFieldLocalidadListar.setEditable(false);
        jTextFieldLocalidadListar.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabelDniCon.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabelDniCon.setText("Localidad:");

        jLabelTelCon.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabelTelCon.setText("Provincia:");

        jTextFielProvinciaListar.setEditable(false);
        jTextFielProvinciaListar.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jButtonBuscarCon.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jButtonBuscarCon.setForeground(new java.awt.Color(102, 0, 102));
        jButtonBuscarCon.setMnemonic('B');
        jButtonBuscarCon.setText("Buscar");
        jButtonBuscarCon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscarConActionPerformed(evt);
            }
        });

        jLabelDireccionCon.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabelDireccionCon.setText("Pais:");

        jTextFielPaisListar.setEditable(false);
        jTextFielPaisListar.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel7.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel7.setText("DNI:");

        jTextFielDNIListar.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel1.setText("Apellido:");

        jLabel6.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel6.setText("Nombre:");

        jLabel8.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel8.setText("Dirección:");

        jTextDireccion.setEditable(false);
        jTextDireccion.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jTextNombre.setEditable(false);
        jTextNombre.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jTextNombre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextNombreActionPerformed(evt);
            }
        });

        jTextApellido.setEditable(false);
        jTextApellido.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jTextApellido.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextApellidoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout ButtBuscarLayout = new javax.swing.GroupLayout(ButtBuscar);
        ButtBuscar.setLayout(ButtBuscarLayout);
        ButtBuscarLayout.setHorizontalGroup(
            ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ButtBuscarLayout.createSequentialGroup()
                .addGap(139, 139, 139)
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel7)
                    .addComponent(jLabel1)
                    .addComponent(jLabel6)
                    .addComponent(jLabel8)
                    .addComponent(jLabelDireccionCon)
                    .addComponent(jLabelTelCon)
                    .addComponent(jLabelDniCon))
                .addGap(38, 38, 38)
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ButtBuscarLayout.createSequentialGroup()
                        .addComponent(jTextFielDNIListar, javax.swing.GroupLayout.DEFAULT_SIZE, 335, Short.MAX_VALUE)
                        .addGap(49, 49, 49)
                        .addComponent(jButtonBuscarCon)
                        .addGap(211, 211, 211))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ButtBuscarLayout.createSequentialGroup()
                        .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jTextFieldLocalidadListar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE)
                            .addComponent(jTextFielProvinciaListar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE)
                            .addComponent(jTextFielPaisListar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE)
                            .addComponent(jTextDireccion, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE)
                            .addComponent(jTextNombre, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE)
                            .addComponent(jTextApellido, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE))
                        .addGap(336, 336, 336))))
        );
        ButtBuscarLayout.setVerticalGroup(
            ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ButtBuscarLayout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonBuscarCon)
                    .addComponent(jTextFielDNIListar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addGap(61, 61, 61)
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jTextApellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addGap(18, 18, 18)
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addGap(18, 18, 18)
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelDireccionCon)
                    .addComponent(jTextFielPaisListar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ButtBuscarLayout.createSequentialGroup()
                        .addGap(32, 32, 32)
                        .addComponent(jLabelTelCon))
                    .addGroup(ButtBuscarLayout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jTextFielProvinciaListar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ButtBuscarLayout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(jLabelDniCon))
                    .addGroup(ButtBuscarLayout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jTextFieldLocalidadListar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(42, 42, 42))
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(ButtBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(11, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(ButtBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 389, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(48, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Listar Transportista", jPanel3);

        jButtonSalir.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jButtonSalir.setForeground(new java.awt.Color(102, 0, 102));
        jButtonSalir.setText("Salir");
        jButtonSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSalirActionPerformed(evt);
            }
        });

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Usuario Registrado", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 11), new java.awt.Color(102, 0, 102))); // NOI18N

        jTextFieldUsuario2.setEditable(false);
        jTextFieldUsuario2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTextFieldUsuario2, javax.swing.GroupLayout.DEFAULT_SIZE, 157, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTextFieldUsuario2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(28, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButtonSalir)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 934, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(39, 39, 39)
                        .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(19, 19, 19))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(381, 381, 381))
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonSalir)
                .addGap(31, 31, 31))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-1207)/2, (screenSize.height-573)/2, 1207, 573);
    }// </editor-fold>//GEN-END:initComponents

    private void refresh() {
        jTextFieldapellido.setText("");
        jTextFieldnombre.setText("");
        jTextFieldnumeroDocumento.setText("");
        //   jTextFieldcuil.setText("");
        jTextFielddireccion.setText("");
        jTextFieldcodigoPostal.setText("");
        jTextFieldtelefono1.setText("");
        //  jTextFieldtelefono2.setText("");
    }

private void jTableOperariosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableOperariosMouseClicked
    cargarCampos();
}//GEN-LAST:event_jTableOperariosMouseClicked

private void jButtonSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSalirActionPerformed
    this.dispose();
}//GEN-LAST:event_jButtonSalirActionPerformed

////////////////////////////ALTA TRANSPORTISTA////////////////////////////
private void jButtonGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGuardarActionPerformed
    boolean ver = false;
    Tipodocumento tipodocper = null;
    Estadooperario estadoper = null;
    Pais paisper = null;
    Provincia provinciaper = null;
    Localidad localidadper = null;
    nombre = jTextFieldnombre.getText();
    apellido = jTextFieldapellido.getText();
    numerodoc = (jTextFieldnumeroDocumento.getText());
    direccion = jTextFielddireccion.getText();

    tipodoc = jComboBoxtipoDocumento.getSelectedItem().toString();

    try {
        tipodocper = controladortd.buscarTipoDocumentoNombre(tipodoc);

    } catch (Exception e) {
    }

//    estadopersona = jComboBoxestadoPersona.getSelectedItem().toString();
//    try {
//        estadoper = controladorep.buscarEstadoPersonaNombre(estadopersona);
//    } catch (Exception e) {
//    }

    pais = jComboBoxpais.getSelectedItem().toString();

    try {
        paisper = controladorpais.buscarPaisNombre(pais);

    } catch (Exception e) {
    }

    provincia = jComboBoxprovincia.getSelectedItem().toString();

    try {
        provinciaper = controladorprov.buscarProvinciaNombre(provincia);

    } catch (Exception e) {
    }

    localidad = jComboBoxlocalidad.getSelectedItem().toString();

    try {
        localidadper = controladorlocal.buscarLocalidadNombre(localidad);

    } catch (Exception e) {
    }

//    rol = jComboBoxRol3.getSelectedItem().toString();
//
//    try {
//        rolper = controladorrol.buscarRolNombre(rol);
//
//    } catch (Exception e) {
//    }
//////////////////////////PARA INCLUIR LA FECHA ACTUAL COMO FECHA DE ALTA ////////////

    fechaAlta = Validador.getInstance().obtenerFechaSistema();
    System.out.println("La fecha de hoy es: " + fechaAlta);
    ////////////////////////////////////////////////////////////////////////////////////
    //  cuil = jTextFieldcuil.getText();
    codigopostal = jTextFieldcodigoPostal.getText();
    String tel1 = jTextFieldtelefono1.getText();
    // String tel2 = jTextFieldtelefono2.getText();
    telefono1 = Integer.parseInt(jTextFieldtelefono1.getText());
    // telefono2 = Integer.parseInt(jTextFieldtelefono2.getText());
    //  fechaAlta = "";
    fechaBaja = "";
    int nroDoc = Integer.parseInt(numerodoc);


    if (verificar(apellido, nombre, tipodoc, numerodoc, direccion, pais, provincia, localidad, codigopostal, tel1)) {
        //  if (ver == true) {


        Transportista transportista = new Transportista();
        System.out.println("transportista " + transportista.toString());
        transportista.setApellidoTransportista(apellido);
        transportista.setNombreTransportista(nombre);
        transportista.setDireccionTransportista(direccion);
        transportista.setTipodocumento(tipodocper);
        transportista.setNroDocTransportista(nroDoc);
        transportista.setPais(paisper);
        transportista.setProvincia(provinciaper);
        transportista.setLocalidad(localidadper);
        transportista.setTelefono(telefono1);


        controladortransportista.guardarTransportista(transportista);
        //Operariorol o = new Operariorol();

        JOptionPane.showMessageDialog(this, "Alta Transportista registrada", "Alta", JOptionPane.INFORMATION_MESSAGE);

        refresh();
        cargarTabla();
        //   cargarComboOperarios();//ojo este carga todos los operarios
        BuscarPedidosPendientes bp = new BuscarPedidosPendientes(op);
        bp.setVisible(true);
        this.dispose();

    }
}//GEN-LAST:event_jButtonGuardarActionPerformed

    private void cargarTipoDocumento() {

        try {
            listatd = controladortd.buscarTodosTipodocumento();
        } catch (Exception e) {
        }
        jComboBoxtipoDocumento.removeAllItems();
        for (int i = 0; i < listatd.size(); i++) {
            Vector fila = new Vector();
            Tipodocumento tipo = (Tipodocumento) listatd.get(i);
            fila.add(tipo.getNombretipo());
            jComboBoxtipoDocumento.addItem(fila.get(0));
        }

    }

    private void cargarComboPaises() {

        try {
            listapais = controladorpais.buscarTodosPais();
        } catch (Exception e) {
        }
        jComboBoxpais.removeAllItems();
        for (int i = 0; i < listapais.size(); i++) {
            Vector fila = new Vector();
            Pais pais = (Pais) listapais.get(i);
            fila.add(pais.getNombrepais());
            jComboBoxpais.addItem(fila.get(0));
        }

    }

    private void cargarComboProvincias(int idpais) {

        Pais estepais = null;
        try {
            estepais = controladorpais.buscarPais_X_idPais(idpais);//el qeu traia seleccionado
            listaprov = controladorprov.buscarTodosProvincia();
        } catch (Exception e) {
        }
        jComboBoxprovincia.removeAllItems();
        for (int j = 0; j < listaprov.size(); j++) {//por cada una de todas las provincias
            Vector fila = new Vector();
            Provincia provincia = (Provincia) listaprov.get(j);
            if (provincia.getPais().equals(estepais)) {
                fila.add(provincia.getNombreprovincia());
                jComboBoxprovincia.addItem(fila.get(0));
            }
        }


    }

    private void cargarComboLocalidades(int idprovincia) {

        Provincia estaprovincia = null;
        try {
            estaprovincia = controladorprov.buscarProvincia_X_idProvincia(idprovincia);
            System.out.println(estaprovincia.getNombreprovincia());
            listaloc = controladorlocal.buscarTodosLocalidad();
        } catch (Exception e) {
        }
        jComboBoxlocalidad.removeAllItems();
        for (int i = 0; i < listaloc.size(); i++) {//para todas las localidades
            Vector fila = new Vector();
            Localidad milocalidad = (Localidad) listaloc.get(i);
            if (milocalidad.getProvincia().equals(estaprovincia)) {
                fila.add(milocalidad.getNombrelocalidad());
                jComboBoxlocalidad.addItem(fila.get(0));
            }
        }
    }

    //////////////MODIFICAR Transportista/////////////////////////
    private void cargarTipoDocumento1() {

        try {
            listatd = controladortd.buscarTodosTipodocumento();
        } catch (Exception e) {
        }
        jComboBoxtipoDocumento1.removeAllItems();
        for (int i = 0; i < listatd.size(); i++) {
            Vector fila = new Vector();
            Tipodocumento tipo = (Tipodocumento) listatd.get(i);
            fila.add(tipo.getNombretipo());
            jComboBoxtipoDocumento1.addItem(fila.get(0));
        }

    }

    private void cargarComboPaises1() {

        try {
            listapais = controladorpais.buscarTodosPais();
        } catch (Exception e) {
        }
        jComboBoxpais1.removeAllItems();
        for (int i = 0; i < listapais.size(); i++) {
            Vector fila = new Vector();
            Pais pais = (Pais) listapais.get(i);
            fila.add(pais.getNombrepais());
            jComboBoxpais1.addItem(fila.get(0));
        }

    }

    private void cargarComboProvincias1() {

        try {
            listaprov = controladorprov.buscarTodosProvincia();
        } catch (Exception e) {
        }
        jComboBoxprovincia1.removeAllItems();
        for (int i = 0; i < listaprov.size(); i++) {
            Vector fila = new Vector();
            Provincia provincia = (Provincia) listaprov.get(i);
            fila.add(provincia.getNombreprovincia());
            jComboBoxprovincia1.addItem(fila.get(0));
        }
    }

    private void cargarComboLocalidades1() {
        try {
            listaloc = controladorlocal.buscarTodosLocalidad();
        } catch (Exception e) {
        }
        jComboBoxlocalidad1.removeAllItems();
        for (int i = 0; i < listaloc.size(); i++) {
            Vector fila = new Vector();
            Localidad localidad = (Localidad) listaloc.get(i);
            fila.add(localidad.getNombrelocalidad());
            jComboBoxlocalidad1.addItem(fila.get(0));
        }
    }

    /* private void cargarComboTransportistas() {
    System.out.println("cargo combo transportistas");
    try {
    listaTransportista = controladortransportista.buscarTodosTransportista();
    } catch (Exception e) {
    }
    jComboBoxTransportista.removeAllItems();
    for (int i = 0; i < listaTransportista.size(); i++) {
    Vector fila = new Vector();
    Transportista transportista = (Transportista) listaTransportista.get(i);
    fila.add(transportista.getApellidoTransportista() + "," + transportista.getNombreTransportista());
    jComboBoxTransportista.addItem(fila.get(0));

    }
    }*/

    /*   private void actualizarCombo(List lista1) {
    jComboBoxTransportista.removeAllItems();
    for (int i = 0; i < lista1.size(); i++) {
    Vector fila = new Vector();
    Operario operario = (Operario) lista1.get(i);
    fila.add(operario.getCuil());
    jComboBoxTransportista.addItem(fila.get(0));
    }
    }
     */
    public void actualizarDatos(Operario operarioSel) {

        jTextFieldapellido1.setText(operarioSel.getApellido());
        jTextFieldnombre1.setText(operarioSel.getNombre());
        //jTextFieldcuil1.setText(operarioSel.getCuil());
        jTextFieldnumeroDocumento1.setText(String.valueOf(operarioSel.getNumerodocumento()));
        jTextFielddireccion1.setText(operarioSel.getDireccion());
        jTextFieldtelefono1.setText(String.valueOf(operarioSel.getTelefono1()));
        //jTextFieldtelefono2.setText(String.valueOf(operarioSel.getTelefono2()));


    }

private void modificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_modificarActionPerformed
    Tipodocumento tipodocper = null;
    Estadooperario estadoper = null;

    Pais paisper = null;
    Provincia provinciaper = null;
    Localidad localidadper = null;
    boolean ver = false;
    int ind = jTableOperarios.getSelectedRow();
    Transportista t = new Transportista();
    t = (Transportista) listao.get(ind);
    int idt = t.getIdTransportista();
    Transportista transportista = controladortransportista.buscarTransportista_X_idTransportista(idt);

    if (ind < 0) {
        JOptionPane.showMessageDialog(this, "Seleccione un transportista", "Modificar Transportista", JOptionPane.INFORMATION_MESSAGE);
    } else {

        nombre = jTextFieldnombre1.getText();
        apellido = jTextFieldapellido1.getText();

        tipodoc = jComboBoxtipoDocumento1.getSelectedItem().toString();

        try {
            tipodocper = controladortd.buscarTipoDocumentoNombre(tipodoc);

        } catch (Exception e) {
        }

        numerodoc = jTextFieldnumeroDocumento1.getText();
        direccion = jTextFielddireccion1.getText();


        pais = jComboBoxpais1.getSelectedItem().toString();

        try {
            paisper = controladorpais.buscarPaisNombre(pais);

        } catch (Exception e) {
        }

        provincia = jComboBoxprovincia1.getSelectedItem().toString();

        try {
            provinciaper = controladorprov.buscarProvinciaNombre(provincia);

        } catch (Exception e) {
        }

        localidad = jComboBoxlocalidad1.getSelectedItem().toString();

        try {
            localidadper = controladorlocal.buscarLocalidadNombre(localidad);

        } catch (Exception e) {
        }

//        rol = jComboBoxRol1.getSelectedItem().toString();


//        try {
//            rolper = controladorrol.buscarRolNombre(rol);
//
//        } catch (Exception e) {
//        }
//
        codigopostal = jTextFieldcodigoPostal1.getText();
        String tel3 = jTextFieldtelefono3.getText();
        //  String tel4 = jTextFieldtelefono4.getText();
        fechaAlta = ""; //esta fecha no se debería poder modificar
        fechaBaja = "";//esta fecha se da al eliminar
        int nroDoc = Integer.parseInt(numerodoc);

        // transportista = new Transportista();


        if (verificar(apellido, nombre, tipodoc, numerodoc, direccion, pais, provincia, localidad, codigopostal, jTextFieldtelefono3.getText())) {



            transportista.setIdTransportista(idt);
            transportista.setApellidoTransportista(apellido);
            transportista.setNombreTransportista(nombre);
            transportista.setTipodocumento(tipodocper);
            transportista.setNroDocTransportista(nroDoc);
            transportista.setDireccionTransportista(direccion);
            transportista.setPais(paisper);
            transportista.setProvincia(provinciaper);
            transportista.setLocalidad(localidadper);
            transportista.setTelefono(telefono1);

            try {
                controladortransportista.modificarTransportista(transportista);
                JOptionPane.showMessageDialog(this, "La modificación fue realizada de forma Exitosa!", "Modificar Transportista", JOptionPane.INFORMATION_MESSAGE);

            } catch (Exception ex) {
                ex.printStackTrace();
            }
            JOptionPane.showMessageDialog(this, "La modificación fue realizada de forma Exitosa!", "Modificar Transportista", JOptionPane.INFORMATION_MESSAGE);
            cargarTabla();
            BuscarPedidosPendientes bp = new BuscarPedidosPendientes(op);
            bp.setVisible(true);
            this.dispose();
        }
    }

}//GEN-LAST:event_modificarActionPerformed

private void jTextFieldapellido1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldapellido1ActionPerformed
}//GEN-LAST:event_jTextFieldapellido1ActionPerformed
    private void cargarCampos() {
        int fila = jTableOperarios.getSelectedRow();
        Estadooperario esteestado = null;
        int nroestado;
        int nropais;
        int nroprov;
        int nroloc;
        int nrotipo;

        Transportista transportista = new Transportista();
        transportista = (Transportista) listao.get(fila);
        jTextFieldapellido1.setText(transportista.getApellidoTransportista());
        jTextFieldnombre1.setText(transportista.getNombreTransportista());
        //    jTextFieldcuil1.setText(operario.getCuil());
////Estadopersona
//        nroestado = transportista.getEstadooperario().getIdestadooperario();
//
//        String nro = String.valueOf(nroestado);
//        int nroEstado = Integer.parseInt(nro) - 1;//es menos 1 por el indice que empieza en cero
//        // jComboBoxestadoPersona1.setSelectedIndex(nroEstado);


        jTextFieldnumeroDocumento1.setText(String.valueOf(transportista.getNroDocTransportista()));
//Pais
      /*  nropais = transportista.getPais().getIdpais();
        String npais = String.valueOf(nropais);
        int nroPais = Integer.parseInt(npais) - 1;
        jComboBoxpais1.setSelectedIndex(nroPais);
        //provincia
        nroprov = transportista.getProvincia().getIdprovincia();
        String nprov = String.valueOf(nroprov);
        int nroProv = Integer.parseInt(nprov) - 1;
        jComboBoxprovincia1.setSelectedIndex(nroProv);
        ;
        //Localidad
        nroloc = transportista.getLocalidad().getIdlocalidad();
        String nloc = String.valueOf(nroloc);
        int nroLoc = Integer.parseInt(nloc) - 1;
        jComboBoxlocalidad1.setSelectedIndex(nroLoc);*/
        jTextFielddireccion1.setText(transportista.getDireccionTransportista());

        jTextFieldcodigoPostal1.setText(transportista.getLocalidad().getCodigopostal());

        jTextFieldtelefono3.setText(String.valueOf(transportista.getTelefono()));

        //    jTextFieldtelefono4.setText(String.valueOf(operario.getTelefono2()));
    }

    private void cargarTabla() {
        String[] encabezados = new String[7];
        encabezados[0] = "Apellido";
        encabezados[1] = "Nombre";
        encabezados[2] = "Nro Documento";
        encabezados[3] = "Nro Telefono1";
        encabezados[4] = "Pais";
        encabezados[5] = "Provincia";
        encabezados[6] = "Localidad";

        tableModel = new TablaPersonalizada(encabezados);
        jTableOperarios.setModel(tableModel);

        try {
            listao = controladortransportista.buscarTodosTransportista();
            System.out.println("tamaño de listao" + listao.size());

            for (int i = 0; i < listao.size(); i++) {
                Vector fila = new Vector();
                Transportista transportista = (Transportista) listao.get(i);
                fila.add(transportista.getApellidoTransportista());
                fila.add(transportista.getNombreTransportista());
                fila.add(transportista.getNroDocTransportista());
                fila.add(transportista.getTelefono());
                fila.add(transportista.getPais().getNombrepais());
                fila.add(transportista.getProvincia().getNombreprovincia());
                fila.add(transportista.getLocalidad().getNombrelocalidad());
                tableModel.addRow(fila);
            }
        } catch (Exception e) {
        }
    }

    private void limpiarCampos() {
        jTextFieldapellido1.setText("");
        jTextFieldnombre1.setText("");
        jTextFielddireccion1.setText("");
        jTextFieldcodigoPostal1.setText("");
        //    jTextFieldcuil1.setText("");
        jTextFieldnumeroDocumento1.setText("");
        jTextFieldtelefono3.setText("");
        //     jTextFieldtelefono4.setText("");
    }

///////////////////ELIMINAR OPERARIO////////////////////////////////////////
private void eliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eliminarActionPerformed
    int ind = jTableOperarios.getSelectedRow();
    if (ind < 0) {
        JOptionPane.showMessageDialog(this, "Seleccione un Transportista", "Eliminar Transportista", JOptionPane.INFORMATION_MESSAGE);
    } else {
        Transportista u = (Transportista) listao.get(ind);
        int rta = JOptionPane.showConfirmDialog(this, "Esta seguro de que desea ELIMINAR el Transportista:\n  =  ?", "Eliminar Transportista", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
        if (rta == 0) {
            try {
                controladortransportista.eliminarTransportista(u);
            } catch (Exception ex) {
                // JOptionPane.showMessageDialog(this, "No se puede eliminar este transportista se incluirá esta fecha como fecha de baja", "Eliminar Transportista", JOptionPane.INFORMATION_MESSAGE);
            }

            JOptionPane.showMessageDialog(this, "Transportista Eliminado!", "Eliminar Transportista", JOptionPane.INFORMATION_MESSAGE);
            cargarTabla();

            limpiarCampos();
            BuscarPedidosPendientes bp = new BuscarPedidosPendientes(op);
            bp.setVisible(true);
            this.dispose();
        }
    }
}//GEN-LAST:event_eliminarActionPerformed

private void jButtonBuscarConActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscarConActionPerformed
///////////////

    // Transportista transportista = null;
    int numero = Integer.parseInt(jTextFielDNIListar.getText());
//    String nombrecuil = estetransportista.toString();
//    // System.out.println("nombre cuil " + nombrecuil);
    try {
        transportista = controladortransportista.buscarTransportista_X_nroDocumento(numero);
//        //   System.out.println("mioperar " + mioperar);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, "El operario ingresado no se ha encontrado.\n ", "Operarios", JOptionPane.ERROR_MESSAGE);
    }



    if (transportista != null) {
        jTextApellido.setText(transportista.getApellidoTransportista());
        jTextNombre.setText(transportista.getNombreTransportista());
        jTextDireccion.setText(transportista.getDireccionTransportista());
        jTextFieldLocalidadListar.setText(transportista.getLocalidad().getNombrelocalidad());
        jTextFielProvinciaListar.setText(transportista.getProvincia().getNombreprovincia());
        jTextFielPaisListar.setText(transportista.getPais().getNombrepais());

    }
}//GEN-LAST:event_jButtonBuscarConActionPerformed

//este da error porque devuelve nulo ya que no hay ninguna provincia seleccionada da nul pointer exception  /*  public void mostrarCodigoPostal(String codigo) {
private void jComboBoxtipoDocumentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxtipoDocumentoActionPerformed
    Tipodocumento mitipodoc = null;
    Object estedoc = jComboBoxtipoDocumento.getSelectedItem();
    String nombretipodoc = estedoc.toString();//nombre del pais
    try {
        mitipodoc = controladortd.buscarTipoDocumentoNombre(nombretipodoc);
    } catch (Exception e) {
    }

}//GEN-LAST:event_jComboBoxtipoDocumentoActionPerformed

/////////////////LISTAR////////////////////
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    jPanel4.setVisible(true);    // TODO add your handling code here:
}//GEN-LAST:event_jButton1ActionPerformed

private void jTextApellidoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextApellidoActionPerformed
    // TODO add your handling code here:
}//GEN-LAST:event_jTextApellidoActionPerformed

private void jTextNombreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextNombreActionPerformed
    // TODO add your handling code here:
}//GEN-LAST:event_jTextNombreActionPerformed
//////////////////LISTAR///////////////
//Ojo qeu no verifica bien el telefono. da error cuando se ingresa una letra.

    private boolean verificar(String ape, String nom, String tipodoc, String nrodoc, String direccion, String pais, String provincia, String localidad, String codigopostal, String telefono1) {

        boolean ver = false;
        if (ape.equals("") || nom.equals("") || tipodoc.equals("") || nrodoc.equals("") || direccion.equals("") || pais.equals("") || provincia.equals("") || localidad.equals("") || codigopostal.equals("") || telefono1.equals("")) {
            JOptionPane.showMessageDialog(this, "Por favor llene todos los campos!!!", "Error", JOptionPane.ERROR_MESSAGE);

        } else if (!validador.getInstance().soloContieneLetras(ape)) {
            JOptionPane.showMessageDialog(this, "Apellido invalido!!!", "Error", JOptionPane.ERROR_MESSAGE);

        } else if (!validador.getInstance().soloContieneLetrasYEspacios(nom)) {
            JOptionPane.showMessageDialog(this, "Nombre invalido!!!", "Error", JOptionPane.ERROR_MESSAGE);

        } else if (!validador.getInstance().soloContieneNumeros(nrodoc)) {
            JOptionPane.showMessageDialog(this, "Número de documento invalido!!!", "Error", JOptionPane.ERROR_MESSAGE);

//        } else if (!validador.getInstance().soloContieneNumerosYGuiones(cuil)) {
//            JOptionPane.showMessageDialog(this, "Cuil invalida!!!", "Error", JOptionPane.ERROR_MESSAGE);

        } else if (!validador.getInstance().soloContieneLetrasYNumerosYEspacios(direccion)) {

            JOptionPane.showMessageDialog(this, "Dirección invalido!!!", "Error", JOptionPane.ERROR_MESSAGE);

        } else if (!validador.getInstance().esTelefonoValido(telefono1)) {
            JOptionPane.showMessageDialog(this, "El valor ingresado para telefono1 es incorrecto!!!", "Error", JOptionPane.ERROR_MESSAGE);


        } else {
            ver = true;
        }
        return ver;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel ButtBuscar;
    private javax.persistence.EntityManager GestorPesajeJpaPU2EntityManager;
    private javax.swing.JButton eliminar;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButtonBuscarCon;
    private javax.swing.JButton jButtonGuardar;
    private javax.swing.JButton jButtonSalir;
    private javax.swing.JComboBox jComboBoxlocalidad;
    private javax.swing.JComboBox jComboBoxlocalidad1;
    private javax.swing.JComboBox jComboBoxpais;
    private javax.swing.JComboBox jComboBoxpais1;
    private javax.swing.JComboBox jComboBoxprovincia;
    private javax.swing.JComboBox jComboBoxprovincia1;
    private javax.swing.JComboBox jComboBoxtipoDocumento;
    private javax.swing.JComboBox jComboBoxtipoDocumento1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabelDireccionCon;
    private javax.swing.JLabel jLabelDniCon;
    private javax.swing.JLabel jLabelTelCon;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTableOperarios;
    private javax.swing.JTextField jTextApellido;
    private javax.swing.JTextField jTextDireccion;
    private javax.swing.JTextField jTextFielDNIListar;
    private javax.swing.JTextField jTextFielPaisListar;
    private javax.swing.JTextField jTextFielProvinciaListar;
    private javax.swing.JTextField jTextFieldLocalidadListar;
    private javax.swing.JTextField jTextFieldUsuario2;
    private javax.swing.JTextField jTextFieldapellido;
    private javax.swing.JTextField jTextFieldapellido1;
    private javax.swing.JTextField jTextFieldcodigoPostal;
    private javax.swing.JTextField jTextFieldcodigoPostal1;
    private javax.swing.JTextField jTextFielddireccion;
    private javax.swing.JTextField jTextFielddireccion1;
    private javax.swing.JTextField jTextFieldnombre;
    private javax.swing.JTextField jTextFieldnombre1;
    private javax.swing.JTextField jTextFieldnumeroDocumento;
    private javax.swing.JTextField jTextFieldnumeroDocumento1;
    private javax.swing.JTextField jTextFieldtelefono1;
    private javax.swing.JTextField jTextFieldtelefono3;
    private javax.swing.JTextField jTextNombre;
    private javax.swing.JButton modificar;
    private java.util.List<Entidades.Tipodocumento> tipodocumentoList;
    private javax.persistence.Query tipodocumentoQuery;
    // End of variables declaration//GEN-END:variables

    private boolean verificar(String cuil) {
        boolean ver = false;

        if (cuil.equals("")) {
            JOptionPane.showMessageDialog(this, "Por favor ingrese el cuil del operario!!!", "Error", JOptionPane.ERROR_MESSAGE);
        } else if (!validador.getInstance().soloContieneNumerosYGuiones(cuil)) {
            JOptionPane.showMessageDialog(this, "Cuil incorrecto: Ingrese números y guiones para cuil!!!", "Error", JOptionPane.ERROR_MESSAGE);
            //  } else if (!repetidoOperario(cuil) == false) {
            //    JOptionPane.showMessageDialog(this, "Error el numero de cuil pertenece a otro operario !!!", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            ver = true;
        }

        return ver;
    }
//    private boolean repetidoOperario(String cuil) {
//        boolean estarepetido = false;
//        Operario operarc = new Operario();
//        try {
//            operarc = controladorop.buscarOperarioCuil(cuil);
//            estarepetido = true;
//            System.out.println("Encontró el cuil en un operario");
//        } catch (Exception e) {
//            estarepetido = false;
//            System.out.println("NO está repetido el cuil en otro operario");
//        }
//        return estarepetido;
//    }
//    private void cargarComboRol() {
//        try {
//            listarol = controladorrol.buscarTodosRol();
//        } catch (Exception e) {
//        }
//        jComboBoxRol.removeAllItems();
//        for (int i = 0; i < listarol.size(); i++) {
//            Vector fila = new Vector();
//            Rol rol = (Rol) listarol.get(i);
//            fila.add(rol.getNombreRol());
//            jComboBoxRol.addItem(fila.get(0));
//        }
//
//    }
//    private void cargarComboCuil1() {
//        try {
//            listao = controladorop.buscarTodosOperario();
//            System.out.println("tamaño de la lista de cuil 1: " + listao.size());
//        } catch (Exception e) {
//        }
//        jComboBoxCuil1.removeAllItems();
//        for (int i = 0; i < listao.size(); i++) {
//            Vector fila = new Vector();
//            Operario operari = (Operario) listao.get(i);
//            fila.add(operari.getCuil());
//            jComboBoxCuil1.addItem(fila.get(0));
//        }
//    }
//    private void cargarComboArea() {
//        try {
//            listaarea = controladorarea.buscarTodosArea();
//            System.out.println("tamaño de listaarea: " + listaarea.size());
//        } catch (Exception e) {
//        }
//        jComboBoxArea.removeAllItems();
//        for (int i = 0; i < listaarea.size(); i++) {
//            Vector fila = new Vector();
//            Area area = (Area) listaarea.get(i);
//            fila.add(area.getNombreArea());
//            jComboBoxArea.addItem(fila.get(0));
//        }
//
//    }
//    private void cargarComboCargo() {
//        try {
//            listacargo = controladorcargo.buscarTodosCargo();
//            System.out.println("tamaño de listacargo: " + listaarea.size());
//        } catch (Exception e) {
//        }
//        jComboBoxCargo.removeAllItems();
//        for (int i = 0; i < listacargo.size(); i++) {
//            Vector fila = new Vector();
//            Cargo cargo = (Cargo) listacargo.get(i);
//            fila.add(cargo.getNombreCargo());
//            jComboBoxCargo.addItem(fila.get(0));
//        }
//
//    }
//    private void cargarComboRol2() {
//        try {
//            listarol = controladorrol.buscarTodosRol();
//        } catch (Exception e) {
//        }
//        jComboBoxRol.removeAllItems();
//        for (int i = 0; i < listarol.size(); i++) {
//            Vector fila = new Vector();
//            Rol rol = (Rol) listarol.get(i);
//            fila.add(rol.getNombreRol());
//            jComboBoxRol.addItem(fila.get(0));
//        }
//    }
//    private void cargarComboRol(int idcargo) {
//         Cargo estecargo = null;
//        try {
//            estecargo = controladorcargo.buscarCargo_X_idCargo(idcargo);//el qeu traia seleccionado
//            listarol = controladorrol.buscarTodosRol();
//        } catch (Exception e) {
//        }
//        jComboBoxRol.removeAllItems();
//        for (int j = 0; j < listarol.size(); j++) {//por cada una de todas las provincias
//            Vector fila = new Vector();
//            Rol rol = (Rol) listarol.get(j);
//            if (rol.getIdRol().equals(estecargo)) {
//                fila.add(rol.getNombreRol());
//                jComboBoxRol.addItem(fila.get(0));
//            }
//        }
//   }
//    private void cargarComboCargo(int idArea) {
//       Area estaarea = null;
//        try {
//            estaarea = controladorarea.buscarArea_X_idArea(idArea);//el qeu traia seleccionado
//            listacargo = controladorcargo.buscarTodosCargo();
//        } catch (Exception e) {
//        }
//        jComboBoxCargo.removeAllItems();
//        for (int j = 0; j < listacargo.size(); j++) {//
//            Vector fila = new Vector();
//            Cargo cargo = (Cargo) listacargo.get(j);
//            if (cargo.getIdCargo().equals(estaarea)) {
//                fila.add(cargo.getNombreCargo());
//                jComboBoxCargo.addItem(fila.get(0));
//            }
//        }
//    }

    private void rellenaCombo2(String pais) {
        Pais mipais = null;
        // Object estepais = jComboBoxpais.getSelectedItem();
        String nombrepais = pais;//nombre del pais
        try {
            mipais = controladorpais.buscarPaisNombre(nombrepais);
        } catch (Exception e) {
        }

        cargarComboProvincias(mipais.getIdpais());//donde las provincias que se carguen pertenezcan al pais seleccionado

        //  Provincia miprovincia = null;

        /*  String nombreprovincia = estaprovincia.toString();
        try {
        miprovincia = controladorprov.buscarProvinciaNombre(nombreprovincia);
        } catch (Exception e) {
        }
        //Object estaprovincia = jComboBoxprovincia.getSelectedItem();*/
        //




    }

    private void rellenaCombo3(String provincia) {
        Provincia miprovincia = null;
// Object estaprovincia = jComboBoxprovincia.getSelectedItem();
        String nombreprovincia = provincia;
        try {
            miprovincia = controladorprov.buscarProvinciaNombre(nombreprovincia);
            cargarComboLocalidades(miprovincia.getIdprovincia());
        } catch (Exception e) {
        }

        /* Localidad mislocalidades = null;
        Object estalocalidad = jComboBoxlocalidad.getSelectedItem();
        System.out.println(estalocalidad.toString());
        try {
        mislocalidades = controladorlocal.buscarLocalidadNombre(estalocalidad.toString());
        } catch (Exception e) {
        System.out.println(e);
        }
        mostrarCodigoPostal(mislocalidades.getCodigopostal());*/
    }

    private void rellenaCombo4(String loc) {
        Localidad mislocalidades = null;
        // String estalocalidad = loc;
        //String codigopostal = "";
        System.out.println(loc);
        try {
            mislocalidades = controladorlocal.buscarLocalidadNombre(loc);
            String cp = mislocalidades.getCodigopostal();
            jTextFieldcodigoPostal.setText(cp);
        } catch (Exception e) {
            System.out.println(e);
        }

    }

    private void rellenaCombo5(String pais) {
        Pais mipais1 = null;
        // Object estepais = jComboBoxpais.getSelectedItem();
        String nombrepais1 = pais;//nombre del pais
        try {
            mipais1 = controladorpais.buscarPaisNombre(nombrepais1);
        } catch (Exception e) {
        }

        cargarComboProvincias1(mipais1.getIdpais());//donde las provincias que se carguen pertenezcan al pais seleccionado

        //  Provincia miprovincia = null;

        /*  String nombreprovincia = estaprovincia.toString();
        try {
        miprovincia = controladorprov.buscarProvinciaNombre(nombreprovincia);
        } catch (Exception e) {
        }
        //Object estaprovincia = jComboBoxprovincia.getSelectedItem();*/
        //




    }

    private void rellenaCombo6(String provincia) {
        Provincia miprovincia1 = null;
// Object estaprovincia = jComboBoxprovincia.getSelectedItem();
        String nombreprovincia1 = provincia;
        try {
            miprovincia1 = controladorprov.buscarProvinciaNombre(nombreprovincia1);
            cargarComboLocalidades1(miprovincia1.getIdprovincia());
        } catch (Exception e) {
        }

        /* Localidad mislocalidades = null;
        Object estalocalidad = jComboBoxlocalidad.getSelectedItem();
        System.out.println(estalocalidad.toString());
        try {
        mislocalidades = controladorlocal.buscarLocalidadNombre(estalocalidad.toString());
        } catch (Exception e) {
        System.out.println(e);
        }
        mostrarCodigoPostal(mislocalidades.getCodigopostal());*/
    }

    private void rellenaCombo7(String loc) {
        Localidad mislocalidades1 = null;
        // String estalocalidad1 = loc;
        // String codigopostal1 = "";
        System.out.println(loc + "loc1");
        try {
            mislocalidades1 = controladorlocal.buscarLocalidadNombre(loc);
            String cp1 = mislocalidades1.getCodigopostal();
            System.out.println(cp1 + "codigopostal1");
            jTextFieldcodigoPostal1.setText(cp1);
        } catch (Exception e) {
            System.out.println(e);
        }

    }

    private void cargarComboLocalidades1(int idprovincia) {

        Provincia estaprovincia = null;
        try {
            estaprovincia = controladorprov.buscarProvincia_X_idProvincia(idprovincia);
            System.out.println(estaprovincia.getNombreprovincia());
            listaloc = controladorlocal.buscarTodosLocalidad();
        } catch (Exception e) {
        }
        jComboBoxlocalidad1.removeAllItems();
        for (int i = 0; i < listaloc.size(); i++) {//para todas las localidades
            Vector fila = new Vector();
            Localidad milocalidad = (Localidad) listaloc.get(i);
            if (milocalidad.getProvincia().equals(estaprovincia)) {
                fila.add(milocalidad.getNombrelocalidad());
                jComboBoxlocalidad1.addItem(fila.get(0));
            }
        }
    }

    private void cargarComboProvincias1(int idpais) {

        Pais estepais = null;
        try {
            estepais = controladorpais.buscarPais_X_idPais(idpais);//el qeu traia seleccionado
            listaprov = controladorprov.buscarTodosProvincia();
        } catch (Exception e) {
        }
        jComboBoxprovincia1.removeAllItems();
        for (int j = 0; j < listaprov.size(); j++) {//por cada una de todas las provincias
            Vector fila = new Vector();
            Provincia provincia = (Provincia) listaprov.get(j);
            if (provincia.getPais().equals(estepais)) {
                fila.add(provincia.getNombreprovincia());
                jComboBoxprovincia1.addItem(fila.get(0));


            }
        }

    }
}
